<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button onclick="login()">登陆</button>
  <button onclick="home()">首页</button>
  <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
  <script>
    axios.defaults.baseURL = 'http://localhost:3000'
    axios.defaults.withCredentials = true // 允许携带凭证  允许携带cookie


    function login() {
      axios.post('/login', {
        username: 'admin',
        password: '123'
      }).then(res => {
        console.log(res);
      })
    }


    function home() {
      axios.get('/home').then(res => {
        console.log(res);
      })
    }
  </script>
</body>

</html>